Source code for /engineering/webperf/slave-v4[j1.2]/ReqQueue.javaOriginal file ReqQueue.java
   1 import java.util.*;
   2 
   3 public class ReqQueue {
   4    
   5    ObjectMonitor   myLock; 
   6    Vector		 queue;  
   7    int 		 queueSize;
   8 
   9    // Use default constructor
  10 
  11    public void init() {
  12 	myLock    = new ObjectMonitor();
  13       queue     = new Vector();
  14       queueSize = 0;
  15    }
  16 
  17    public Request get() {
  18       Request r = null;
  19       // blocks until a message arrives
  20       myLock.lock(true);
  21       if (!queue.isEmpty()) {
  22          r = (Request) queue.elementAt(0);         
  23          queue.removeElementAt(0);
  24 	   queueSize--;
  25       }
  26       myLock.lock(false);
  27       return r;
  28    }
  29    
  30    public void put(Request r) {
  31       myLock.lock(true);
  32       queue.addElement(r);
  33 	queueSize++;
  34       myLock.lock(false);
  35    }
  36    
  37    public int size() {
  38       return queueSize;
  39    }
  40         
  41 }